package net.pessu.android.shoppoid.gui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;

public class TextSolution extends EditText {

	private double solution;

	public TextSolution(Context context) {
		super(context);
	}

	public TextSolution(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public TextSolution(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void setText(double valeur) {
		setSolution(valeur);
		setText(getSolutionText().toString());
	}

	/**
	 * @return the solution
	 */
	public double getSolution() {
		return solution;
	}

	/**
	 * @param solution
	 *            the solution to set
	 */
	public void setSolution(double solution) {
		this.solution = solution;
	}

	/**
	 * @param solution
	 *            the solution to set
	 */
	public String getSolutionText() {
		return new StringBuilder(IhmObjets.df.format(solution)).toString()
				.replace(",", ".");
	}

}
